﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace merge1
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {

        }
        public void btnMergeFiles_Click(object sender, EventArgs e)
        {
            // Show file dialog to select the first file
          
        }

        private void MainForm_MouseClick(object sender, MouseEventArgs e)
        {
          
           
        }

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string file1Path = openFileDialog1.FileName;

                // Show file dialog to select the second file
                OpenFileDialog openFileDialog2 = new OpenFileDialog();
                if (openFileDialog2.ShowDialog() == DialogResult.OK)
                {
                    string file2Path = openFileDialog2.FileName;

                    // Read contents of both files
                    string file1Content = File.ReadAllText(file1Path);
                    string file2Content = File.ReadAllText(file2Path);

                    // Merge contents
                    string mergedContent = file1Content + Environment.NewLine + file2Content;

                    // Create a new file in the Data subdirectory
                    string dataDirectory = Path.Combine(Application.StartupPath, "Data");
                    Directory.CreateDirectory(dataDirectory);
                    string mergedFilePath = Path.Combine(dataDirectory, "MergedFile.txt");

                    // Write merged content to the new file
                    File.WriteAllText(mergedFilePath, mergedContent);

                    MessageBox.Show($"Files merged successfully! Merged file saved at {mergedFilePath}");
                }
            }
        }
    }
    //public partial class Form1 : Form
    //{
    //    public Form1()
    //    {
    //        InitializeComponent();
    //    }


    //}
}
